home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / comm / bbs / cit_src_AD08.lha / sysdep.h < prev    next >
C/C++ Source or Header  |  2000-04-08  |  13KB  |  322 lines

  1. /************************************************************************/
  2. /*                              SysDep.H                                */
  3. /*      #include file for all Citadel C files; contains system          */
  4. /*      dependent code.                                                 */
  5. /************************************************************************/
  6. /*
  7. * This is here because Borland International requires all licensees to place
  8. * copyrights on any distributable s/w.  If you are porting C-86 to another
  9. * machine, you should certainly replace the value here with something else.
  10. * A "" is probably acceptable.
  11. */
  12. #define COPYRIGHT " Custom Services 1998"
  13. #include "fctype.h"
  14. #include "stdio.h"
  15. #include "stdlib.h"
  16. #include "string.h"
  17. #include "exec/types.h"
  18. #include "exec/exec.h"
  19. #include "devices/console.h"
  20. #include "devices/keymap.h"
  21. #include "devices/serial.h"
  22. #include "devices/timer.h"
  23. #include "libraries/dos.h"
  24. #include "libraries/dosextens.h"
  25. #include "intuition/intuition.h"
  26. /* #include "proto/all.h" */
  27. #define ANSI_PROTOTYPING
  28. #define IS_MOTOROLA
  29. #define OUTSIDE_EDITOR_SUPPORT
  30. #define SYSTEM_CLOCK
  31. /**
  32.   Special definitions used in message strings
  33. **/
  34. #define VARIANT_NAME    "Citadel-68k"
  35. #define VERSION_NAME  "(AD08)"
  36. #ifdef _M68020
  37. #define SYSDEP_NAME   "/030"
  38. #else
  39. #define SYSDEP_NAME   "/000"
  40. #endif
  41. /**
  42.   This structure is used by the BadPeople.sys file processing
  43.   to collect the list of suppressed user/room/system names
  44.  
  45.   A * in the field indicates that the comparision for that
  46.   field is skipped and is a match.
  47.  
  48.   An entry of "* * *" would suppress all messages in all
  49.   rooms for all systems.  This is illegal and will be rejected
  50.   as an error.
  51. **/
  52. struct User_Id
  53.   {
  54.   char *name;   /* suppressed user  ( * == all users ) */
  55.   char *room;   /* suppressed room  ( * == all rooms ) */
  56.   char *system; /* suppressed system( * is all systems ) */
  57.   };
  58.  
  59. #define HORRID_AMIGA_LATTICE_BUG
  60.  
  61. /* these are system debug functions.  */
  62. /* note: some are scattered through out the code */
  63. #ifdef NOT_DEFINED_NOW
  64. #define NEED_MSG_PEEKING        /* sysop menu items */
  65. #define NEED_MSG_LIST           /* sysop menu items */
  66. #define NEEDED                    /* sysop menu items */
  67. #define EVENT_DEBUG               /* examine events */
  68. #define NEED_NET_DEBUG          /* network debug messages */
  69. #define NEED_NET_DEBUG_ERRORS   /* network debug messages */
  70. #define NEED_TRANS_NET_DEBUG    /* network debug messages */
  71. #define TEST_SYS                /* enable debug output */
  72. #define NET_DEBUG               /* network debug output */
  73. #endif
  74. #define sPrintf  sprintf
  75.  
  76. void *special_GetDynamic(unsigned size, char *file, int);
  77. #define GetDynamic(size) special_GetDynamic(size,__FILE__,__LINE__)
  78.  
  79.  
  80. /************************************************************************/
  81. /* These constants, etc. are only for use by SYSDEP.C and other source  */
  82. /* files that contain code that depends on the computer system in use.  */
  83. /* Access is via #define in the appropriate source files.               */
  84. /************************************************************************/
  85. /*
  86. * Required! The following MUST be defined:
  87. *   MSG_SECT_SIZE -- size, in bytes, of a (psuedo) "sector" on disk
  88. *                    for the message file
  89. *   SIZE_SYS_FILE -- longest length, in bytes, of a "system" (i.e., *.SYS,
  90. *                    *.BLB, *.MNU, *.HLP, and net files) file plus 1 (for
  91. *                    the NULL byte.  Variables using this constant are used for
  92. *                    defining a name of a file and then opening it.
  93. *   MSG_NUMBER  -- just what is* a message number
  94. *   SECTOR_ID   -- just what to use to identify a sector
  95. *   AN_UNSIGNED -- an unsigned quantity, very preferably 8 bits
  96. *   ROOM_MSG    -- this needs* to be 16 bits, for a kludge in listRooms()
  97. *   DATA_BLOCK[MSG_SECT_SIZE] -- a block of msg data from disk
  98. *   CRC_TYPE    -- sufficient to hold a XMODEM CRC value
  99. *   SYS_FILE    -- a variable used in makeSysName() that holds the "name" of
  100. *                  a system file (see SIZE_SYS_FILE).  This is passed to
  101. *                  safeopen().  Normally, this would be just a string using
  102. *                  the SIZE_SYS_FILE constant, but I can see situations in
  103. *                  which a struct would be more appropriate.  If you have*
  104. *                  to go with a struct, I suggest making safeopen() a macro
  105. *                  that takes the address of the name (see description of
  106. *                  safeopen for its function).  I.e...
  107. *  #define safeopen(x, y)    ourOpen(&x, y)
  108. *   ROOM_AREA   -- definition of an area attached to a room
  109. *   NET_AREA    -- definition of an area accessible to net functions
  110. *   SYS_AREA    -- definition of an area that may be occupied by a Citadel
  111. *                  system file.
  112. *   MODEM_DATA  -- all necessary modem data for this implementation
  113. *
  114. */
  115. #define MSG_SECT_SIZE   128
  116. #define SIZE_SYS_FILE   128             /* Should be enough             */
  117. #define MAX_FILENAME   24
  118. #define LOCKFILE        "ctdllock.sys"
  119. #define DEFAULT_AREXX_PORT  "CITADEL_68K_PORT"
  120. #define MAX_AREXX_PORT_SIZE  (64)
  121. #define ALL_FILES       "*"
  122. #define CACHED_FILES    "*.msg"
  123.  
  124. typedef unsigned long   MSG_NUMBER;       /* Msg number for PClone 32 bits*/
  125. typedef unsigned short  SECTOR_ID;        /* Sector ID -- 16 bits         */
  126. typedef unsigned char   AN_UNSIGNED;
  127. typedef unsigned char   DATA_BLOCK[MSG_SECT_SIZE];
  128. typedef unsigned short  CRC_TYPE;
  129. typedef char            SYS_FILE[SIZE_SYS_FILE];
  130. typedef char            DOMAIN_FILE[40];
  131. typedef unsigned long   MULTI_NET_DATA;
  132. typedef unsigned long   UNS_32;
  133. typedef unsigned short  UNS_16;
  134. struct MenuData
  135.   {
  136.   struct Window *MenuWindow;
  137.   char *MenuCharList;
  138.   struct MsgPort *MenuIOPort;
  139.   struct IOStdReq *MenuIOMsg;
  140.   int DeviceOpen;
  141.  
  142.   };
  143. typedef struct MenuData *MenuId;
  144. #define S_MSG_MASK      0x7fffffffl     /* hi bit, right?       */
  145. #define NO_MENU   NULL
  146. typedef short ROOM_AREA;          /* This might carry the # of the room   */
  147. typedef struct
  148.   {
  149.   char        naDirname[100]; /* Directory anywhere on system         */
  150.  
  151.   }
  152. NET_AREA;
  153. typedef struct
  154.   {
  155.   char  saDirname[64];
  156.  
  157.   }
  158. SYS_AREA;
  159. #define NO_CLOCK        0
  160. #define BUSY_CLOCK      1
  161. #define ALWAYS_CLOCK    2
  162. #define SER_7WIRE       4
  163. struct timePacket
  164.   {
  165.   unsigned long clock[2];
  166.  
  167.   };
  168. typedef struct
  169.   {
  170.   char ARexxPort[MAX_AREXX_PORT_SIZE];  /* ARexx Port name              */
  171.   char Editor[15];                      /* Outside editor name          */
  172.   char EditArea[40];                    /* Where should we do our work? */
  173.   char ModemSetup[60];                  /* First init of modem.         */
  174.   char HiSpeedInit[30];                 /* High speed init              */
  175.   short  Clock;                         /* clock flag                   */
  176.   char LockPort;
  177.   unsigned short ScreenWidth,ScreenHeight,ScreenDepth,Color0,Color1;
  178.   char StartUpEcho,DirectToChip,UnitNumber,DevName[32];
  179.  
  180.   }
  181. DependentData;
  182.  
  183. #define BOOLEAN_FLAG(x)         unsigned x : 1
  184. #define mvToHomeDisk(x)
  185. #define makeVASysName(x, y)     sPrintf(x, "virtual/%s", y)
  186. #define CreateVAName(fn, slot, dir, num) sPrintf(fn, "virtual/%d/%s/%ld", slot, dir, num)
  187. #define ChatEat(c)      c == 0
  188. #define ChatSend(c)     c == 0
  189. #define makeSysName(x, y, z)    sPrintf(x, "%s%s", (z)->saDirname, y)
  190. #define RoomSys(x)      roomBuf.rbArea = x
  191. #define zero_struct(x)     setmem(&x, ( (long)sizeof( x ) & 0x0000ffffL), 0)
  192. #define zero_array(x)      setmem( x, ( (long)sizeof( x ) & 0x0000ffffL), 0)
  193. #define copy_struct(src, dest)  memcpy(&dest, &src, ( (long)sizeof( src )) )
  194. #define copy_array(src, dest)   memcpy(dest,   src, ( (long)sizeof( src )) )
  195. #define copy_ptr(src, dest, s)  memcpy(dest,   src, ( (long)(sizeof( src[0] )) * (long)s) )
  196. #undef  memmove
  197. #define memmove(dest, src, len)  movmem(src, dest, ( (long)len & 0x0000FFFFL) )
  198. #define fastMod outMod          /* temporary */
  199. #define ToTempArea()    MakeTempDir()
  200. extern char TDirBuffer[];
  201. #define KillTempArea()  homeSpace(), rmdir(TDirBuffer)
  202. #define ScreenUser() ScrNewUser()
  203. #define setNetCallBaud(x,y) CitadelBaudRate(minimum(x, cfg.sysBaud),y);
  204. /* sPrintf(temp, "banners\\%s.%d", str, GetSecond()); */
  205. #define makeBanner(x, y, z)     sPrintf(x, "banners/%s.%d", y, z)
  206. #define RedirectName(b, d, f)  sPrintf(b, "%s/%s", d, f);
  207. #define MakeDomainFileName(buffer, Dir, filename) \
  208. sPrintf(buffer, "%s%d/%s", cfg.domainArea.saDirname, Dir, filename)
  209. #define MakeDomainDirectory(x)  DoDomainDirectory(x, FALSE)
  210. #define KillDomainDirectory(x)  DoDomainDirectory(x, TRUE)
  211. #define MakeBioName(buffer, name) \
  212. sPrintf(buffer, "%s%s", cfg.bioArea.saDirname, name)
  213. #define MoveToBioDirectory()    chdir(cfg.bioArea.saDirname);
  214.  
  215.  
  216. #define VirtualCopyFileToFile(fn, vfn)  CitSystem(FALSE, "copy %s %s > nul", fn, vfn)
  217.  
  218. /*
  219.  * These are for handling the net caching stuff.
  220.  */
  221. #define ChangeToCacheDir(x)     chdir(x)
  222. #define NetCacheName(buf, slot, name)       sPrintf(buf, "%snetcache/%d/%s", cfg.netArea.saDirname, slot, name)
  223. #define MakeNetCacheName(buf, slot)       sPrintf(buf, "%snetcache/%d",    cfg.netArea.saDirname, slot)
  224. #define MakeNetCache(buf)                       sPrintf(buf, "%snetcache",       cfg.netArea.saDirname)
  225. #define MakeDeCompressedFilename(fn, Fn)  sPrintf(fn, "%s%s", cfg.netArea.saDirname, Fn)
  226. typedef struct {
  227.         char *FileName;
  228.         char *MenuEntry;
  229.         char *DeWork;
  230.         char *IntWork;
  231.         char *CompWork;
  232. } DeCompElement;
  233.  
  234. extern DeCompElement DeComp[];
  235.  
  236. extern DeCompElement DeComp[];
  237. #define GetCompEnglish(CompType)   DeComp[(CompType) - 1].MenuEntry
  238. #define DeCompAvailable(CompType) (DeComp[(CompType) - 1].DeWork != NULL)
  239. #define AnyCompression() (DeComp[LHA_COMP-1].CompWork != NULL || DeComp[ARC_COMP-1].CompWork != NULL || DeComp[ZOO_COMP-1].CompWork != NULL || DeComp[ZIP_COMP-1].CompWork != NULL)
  240.  
  241. #define netSetNewArea(fd) realSetSpace((fd)->naDirname)
  242.  
  243. #ifndef CONFIGURE
  244. /* we use our own printf in sysdep3.c */
  245. #undef printf
  246. int printf(const char *format, ...);
  247. #endif
  248. /************************************************************************/
  249. /* These constants, etc. are only for use by SYSDEP.C and other source  */
  250. /* files that contain code that depends on the computer system in use.  */
  251. /* Access is via #define in the appropriate source files.               */
  252. /************************************************************************/
  253. #ifdef CONFIGURE
  254. /**
  255.   parameters for checks in confg
  256. **/
  257. #define HELP            0
  258. #define LOG             1
  259. #define ROOM            2
  260. #define MSG             3
  261. #define MSG2            4
  262. #define NET_STUFF       5
  263. #define CALL            6
  264. #define HOLD            7
  265. #define FLOORA          8
  266. #define DOMAIN_STUFF    9
  267. #define TEMP_AREA      10   /* temp files area                    */
  268. #define QWK2           11   /* BBS Packet name defined            */
  269. #define QWK3           12   /* Files Area Defined                 */
  270. #define QWK4           13   /* Maximum number of rooms at once    */
  271. #define QWK5           14   /* Maximum number of messages at once */
  272. #define BIO_AREA       15   /* biography area defined             */
  273. #define QWK1           16   /* location defined                   */
  274. #define MAX_NEEDED     17   /* total number of parameters checked */
  275. /**
  276.   End of CONFG check parameters
  277. **/
  278. #define I_HANGUP        0
  279. #define I_INIT          1
  280. #define I_CARRDET       2
  281. #define I_SET300        3
  282. #define I_SET1200       4
  283. #define I_SET2400       5
  284. #define I_SETHI         6
  285. #define I_CHECKB        7
  286. #define I_ENABLE        8
  287. #define I_DISABLE       9
  288. #define I_SET4800       10
  289. #define I_SET9600       11
  290. #define I_SET14400      12
  291. #define I_SET19200      13
  292. /* Hmmmmmm.  This stuff shouldn't be here, actually. */
  293. #define R_SH_MARK       "&&"    /* Rather than external char    */
  294. #define NON_LOC_NET     "%%"
  295. #endif
  296. /* Or this.  Fix this someday */
  297. #ifdef V_ADMIN
  298. #define R_SH_MARK       "&&"    /* Rather than external char    */
  299. #define NON_LOC_NET     "%%"
  300. #define LOC_NET         "++"
  301. #endif
  302. #define strCmp          strcmp
  303. #define strLen          strlen
  304. #define toUpper         toupper
  305. #define toLower         tolower
  306. #define strCpy          strcpy
  307. #define strCat          strcat
  308. #define isAlpha         isalpha
  309. #define strnCmp         strncmp
  310. #define isSpace         isspace
  311. #define SEEK_CUR                1
  312. #define NO_STAT
  313. /*#define CTDL_BACKGROUND*/
  314. void Intel16ToMotorola(UNS_16 *);
  315. void Intel32ToMotorola(UNS_32 *);
  316. /*
  317. ** Caller Count routines
  318. */
  319. void Update_Caller_Count(void);
  320. long Get_Call_Count(void);
  321. char *Display_Privledges(void);
  322.